import http from '../index'

/**
 * xml查询单项
 * 获取信息
 */
export const _searchItem = (url) => {
  return http({
    url: `/parameter/v1/${url}`,
    method: 'get',
  })
}

/**
 * xml保存单项
 * @param 符合后端要求的键值对
 * 修改信息
 */
export const _saveItem = (url, param) => {
  // console.log('2222', param)

  return http({
    url: `/parameter/v1/${url}`,
    method: 'put',
    data: param,
  })
}

// json
/**
 * json查询单项
 * 获取信息
 */
export const _searchItemJson = (url) => {
  return http({
    url: `master/json/${url}`,
    method: 'get',
  })
}

/**
 * json保存单项
 * @param 符合后端要求的键值对
 * 获取信息
 */
export const _saveItemJson = (url, param) => {
  return http({
    url: `master/json/${url}`,
    method: 'put',
    data: param,
  })
}

//
/**
 * yaml查询单项
 * 获取信息
 */
export const _searchItemYaml = (url) => {
  return http({
    url: `master/yaml/${url}`,
    method: 'get',
  })
}

/**
 * yaml保存单项
 *  @param 符合后端要求的键值对
 * 获取信息
 */
export const _saveItemYaml = (url, param) => {
  return http({
    url: `master/yaml/${url}`,
    method: 'put',
    data: param,
  })
}

/**
 * static 查询单项
 * 获取信息
 */
export const _searchItemStatic = (url) => {
  return http({
    url: `master/${url}`,
    method: 'get',
  })
}

/**
 * static 保存单项
 * @param 符合后端要求的键值对
 * 获取信息
 */
export const _saveItemStatic = (url, param) => {
  return http({
    url: `master/${url}`,
    method: 'put',
    data: param,
  })
}

// 重启配置项
export const _restartItem = (params) => {
  return http({
    url: `/parameter/v1/restart`,
    method: 'put',
    data: params,
  })
}
